<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<!--User: xulf Date: 2018/7/2 Time: 11:42-->
<link th:href="@{/css/labelColor.css}" rel="stylesheet">
<body>
<form id="materialDataForm" role="form" method="post" action="materiel/update">
    <input id="puid" name="puid" type="hidden" th:value="${data.puid}"/><!--th:value="${entity.pBomPuid}"-->
    <div class="form-group">
        <label for="pMaterielCode">物料代码</label>
        <input class="form-control" id="pMaterielCode" name="pMaterielCode" type="text"disabled="disabled"
               th:value="${data.pMaterielCode}"
               placeholder="请输入物料代码"/><!--th:value="${entity.level}"disabled="disabled"-->
    </div>
    <div class="form-group">
        <label for="pMaterielDesc">物料中文描述</label>
        <input class="form-control" id="pMaterielDesc" name="pMaterielDesc" type="text"disabled="disabled"
               th:value="${data.pMaterielDesc}"
               placeholder="请输入物料中文描述"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pMaterielType">物料类型<span>*</span></label>
        <input class="form-control" id="pMaterielType" name="pMaterielType" type="text"disabled="disabled"
               th:value="${data.pMaterielType}"
               placeholder="请输入物料类型"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="factoryCode">工厂代码<span>*</span></label>
        <input class="form-control" id="factoryCode" name="factoryCode" type="text"
               th:value="${data.factoryCode}"
               placeholder="请输入工厂代码"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pMaterielDescEn">物料描述英文</label>
        <input class="form-control" id="pMaterielDescEn" name="pMaterielDescEn" type="text"disabled="disabled"
               th:value="${data.pMaterielDescEn}"
               placeholder="请输入物料描述英文"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pBasicUnitMeasure">基本计量单位</label>
        <input class="form-control" id="pBasicUnitMeasure" name="pBasicUnitMeasure" type="text"
               th:value="${data.pBasicUnitMeasure}"
               placeholder="请输入基本计量单位"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pInventedPart">虚拟件标识</label>
        <input class="form-control" id="pInventedPart" name="pInventedPart" type="text"
               th:value="${data.pInventedPart}"
               placeholder="请输入虚拟件标识"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="resource">采购类型</label>
        <input class="form-control" id="resource" name="resource" type="text"
               th:value="${data.resource}"
               placeholder="请输入采购类型"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pSpareMaterial">备件&原材料双属性标识</label>
        <select class="form-control" name="pSpareMaterial" id="pSpareMaterial" placeholder="请选择备件&原材料双属性标识">
            <option></option> <!--th:selected="${data.getResource()=='MAKE'?true:false}"-->
            <option th:selected="${data.getpSpareMaterial()=='Make&Buy'?true:false}">Make&Buy</option>
        </select>
    </div>
    <div class="form-group">
        <label for="pVinPerNo">VIN前置号</label>
        <input class="form-control" id="pVinPerNo" name="pVinPerNo" type="text"
               th:value="${data.pVinPerNo}"
               placeholder="请输入VIN前置号"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pColorPart">颜色件标识</label>
        <input class="form-control" id="pColorPart" name="pColorPart" type="text"
               th:value="${data.pColorPart}"
               placeholder="请输入颜色件标识"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pHeight">实际重量</label>
        <input class="form-control" id="pHeight" name="pHeight" type="text"
               th:value="${data.pHeight}"
               placeholder="请输入实际重量"/><!--th:value="${entity.level}"-->
    </div>

    <div class="form-group">
        <label for="pInOutSideFlag">内外饰标识</label>
        <input class="form-control" id="pInOutSideFlag" name="pInOutSideFlag" type="text"
               th:value="${data.pInOutSideFlag}"
               placeholder="请输入内外饰标识"/><!--th:value="${entity.level}"-->
    </div>

    <div class="form-group">
        <label for="p3cPartFlag">3C件标识</label>
        <input class="form-control" id="p3cPartFlag" name="p3cPartFlag" type="text"
               th:value="${data.p3cPartFlag}"
               placeholder="请输入3C件标识"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pPartImportantDegree">零件重要度</label>
        <input class="form-control" id="pPartImportantDegree" name="pPartImportantDegree" type="text"
               th:value="${data.pPertainToProjectPuid}"
               placeholder="请输入零件重要度"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pMrpController">MRP控制者</label>
        <input class="form-control" id="pMrpController" name="pMrpController" type="text"
               th:value="${data.pMrpController}"
               placeholder="请输入MRP控制者"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pLoosePartFlag">散件标志</label>
        <select class="form-control" name="pLoosePartFlag" id="pLoosePartFlag" placeholder="请选择是否散件标志">
            <option th:selected="${data.getpLoosePartFlag()==''?true:false}"></option> <!--th:selected="${data.getResource()=='MAKE'?true:false}"-->
            <option th:selected="${data.getpLoosePartFlag()=='Y'?true:false}">Y</option>
            <option th:selected="${data.getpLoosePartFlag()=='N'?true:false}">N</option>
        </select>
    </div>
</form>

<script th:inline="javascript">
    <![CDATA[
    $(function () {
        $('#materialDataForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                pMaterielCode: {
                    message: '物料代码验证失败',
                    validators: {
                        notEmpty: {
                            message: '物料代码不能为空'
                        }
                    }
                },
                pMaterielType: {
                    message: '物料类型验证失败',
                    validators: {
                        notEmpty: {
                            message: '物料类型不能为空'
                        }
                    }
                },
                factoryCode: {
                    message: '工厂代码验证失败',
                    validators: {
                        notEmpty: {
                            message: '工厂代码不能为空'
                        }
                    }
                },
            }
        });
        // 绑定dialog的确定按钮的监听事件
        $("#btnOk", window.top.document).click(function () {
            var bootstrapValidator = $("#materialDataForm", window.top.document).data('bootstrapValidator');
            bootstrapValidator.validate();
            if (bootstrapValidator.isValid()) {
                var url = $("#materialDataForm ", window.top.document).attr('action');
                var myData = JSON.stringify({
                    "puid": $("#puid").val(),
                    "pMaterielCode": $("#pMaterielCode").val(),
                    "pMaterielDesc": $("#pMaterielDesc").val(),
                    "pMaterielType": $("#pMaterielType").val(),
                    "factoryCode": $("#factoryCode").val(),
                    "pMaterielDescEn": $("#pMaterielDescEn").val(),
                    "pBasicUnitMeasure": $("#pBasicUnitMeasure").val(),
                    "pInventedPart": $("#pInventedPart").val(),
                    "resource": $("#resource").val(),
                    "pSpareMaterial": $("#pSpareMaterial").val(),
                    "pVinPerNo": $("#pVinPerNo").val(),
                    "pColorPart": $("#pColorPart").val(),
                    "pHeight": $("#pHeight").val(),
                    "pInOutSideFlag": $("#pInOutSideFlag").val(),
                    "p3cPartFlag": $("#p3cPartFlag").val(),
                    "pPartImportantDegree": $("#pPartImportantDegree").val(),
                    "pMrpController": $("#pMrpController").val(),
                    "pLoosePartFlag": $("#pLoosePartFlag").val(),
                    "projectId":$("#project", window.top.document).val()
                });
                $.ajax({
                    contentType:
                        "application/json",
                    type:
                        'POST',
                    url: url,
                    data: myData,
                    success:
                        function (result) {
                            // $('.modal-dialog', window.top.document).parent('div').remove()
                            // $('body', window.top.document).find('.modal-backdrop').remove();
                            // jquery 调用刷新当前操作的table页面的refresh方法
                            // $(window.parent.document).contents().find(".tab-pane.fade.active.in iframe")[0].contentWindow.doQuery();
                            activeTabBodyRefresh();
                            /*if (result)
                                window.Ewin.alert({message: '修改数据成功!'});
                            else
                                window.Ewin.alert({message: '修改数据失败!'});*/
                            if (result.success) {
                                layer.msg('修改成功', {icon: 1, time: 2000})
                            }
                            else if(!result.success){
                                window.Ewin.alert({message: result.errMsg})
                            }
                        },
                    error: function (status) {
                        window.Ewin.alert({message: status.status + ':修改数据失败!'});
                    }
                });
            }
        });
    })
    $(document).keydown(function(event) {
        if (event.keyCode == 13) {
            $('form').each(function() {
                event.preventDefault();
            });
        }
    });
    ]]>
</script>
<script th:src="@{/layer/layer.js}"></script>
</body>
</html>